#include <SimulationObjectOsg.h>
#include <EDesignerCore.h>

#include <iostream>

#include <Functions.h>

#include <SceneViewer.h>
#include <VisitorChangeSimState.h>
SimulationObjectOsg::SimulationObjectOsg() : SimulationObject()
{

}

SimulationObjectOsg::~SimulationObjectOsg()
{

}

void SimulationObjectOsg::update()
{
    //std::cout<<"SimulationManagerOsg::update-"<<m_timeInterval<<std::endl;
    SceneViewer::instance()->getViewer()->frame();
    double simTime = SceneViewer::instance()->getViewer()->getFrameStamp()->getSimulationTime();
    //std::cout<<"SimulationObjectOsg::update simTime = "<<simTime<<std::endl;
}

void SimulationObjectOsg::updateRunning()
{
    SceneViewer::instance()->getViewer()->frame();

}

void SimulationObjectOsg::updatePausing()
{
    SceneViewer::instance()->getViewer()->frame();
}

void SimulationObjectOsg::updatePausingToUpdate()
{
    //std::cout<<"SimulationObjectOsg::updatePausingToUpdate"<<std::endl;
    //SceneViewer::instance()->setUpdateVisitorMask(0x0);
    VisitorChangeSimState visitor;
    visitor.setEnableCallBack(false);
    SceneViewer::instance()->getModelRoot()->accept(visitor);
}

void SimulationObjectOsg::updateRunningToUpdate()
{
    //std::cout<<"SimulationObjectOsg::updateRunningToUpdate"<<std::endl;

    VisitorChangeSimState visitor;
    visitor.setEnableCallBack(false);
    SceneViewer::instance()->getModelRoot()->accept(visitor);
}

void SimulationObjectOsg::updateToUpdateRunning()
{
    //std::cout<<"SimulationObjectOsg::updateToUpdateRunning"<<std::endl;

    VisitorChangeSimState visitor;
    visitor.setEnableCallBack(true);
    SceneViewer::instance()->getModelRoot()->accept(visitor);
}

void SimulationObjectOsg::updatePausingToUpdateRunning()
{
    //std::cout<<"SimulationObjectOsg::updatePausingToUpdateRunning"<<std::endl;

    VisitorChangeSimState visitor;
    visitor.setEnableCallBack(true);
    SceneViewer::instance()->getModelRoot()->accept(visitor);
}

void SimulationObjectOsg::updateToUpdatePausing()
{
    //std::cout<<"SimulationObjectOsg::updateToUpdatePausing"<<std::endl;

    VisitorChangeSimState visitor;
    visitor.setEnableCallBack(false);
    SceneViewer::instance()->getModelRoot()->accept(visitor);
}

void SimulationObjectOsg::undateRunningToUpdatePausing()
{
    //std::cout<<"SimulationObjectOsg::undateRunningToUpdatePausing"<<std::endl;

    VisitorChangeSimState visitor;
    visitor.setEnableCallBack(false);
    SceneViewer::instance()->getModelRoot()->accept(visitor);
}


